package com.tjec.project.projectLeaderWorkbeanch.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.projectLeaderWorkbeanch.domain.BmsLeaderAgencyHistory;
import com.tjec.project.projectLeaderWorkbeanch.service.IBmsLeaderAgencyHistoryService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 项目负责人委托历史变更记录 Controller
 * 
 * @author pyf
 * @date 2021-04-22
 */
@RestController
@RequestMapping("/projectLeaderWorkbeanch/workflowAgencyHistory")
public class BmsLeaderAgencyHistoryController extends BaseController
{
    @Autowired
    private IBmsLeaderAgencyHistoryService bmsLeaderAgencyHistoryService;

    /**
     * 查询项目负责人委托历史变更记录 列表
     */
    @PreAuthorize("@ss.hasPermi('projectLeaderWorkbeanch:workflowAgencyHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsLeaderAgencyHistory bmsLeaderAgencyHistory)
    {
        startPage();
        List<BmsLeaderAgencyHistory> list = bmsLeaderAgencyHistoryService.selectBmsLeaderAgencyHistoryList(bmsLeaderAgencyHistory);
        return getDataTable(list);
    }

    /**
     * 导出项目负责人委托历史变更记录 列表
     */
    @PreAuthorize("@ss.hasPermi('projectLeaderWorkbeanch:workflowAgencyHistory:export')")
    @Log(title = "项目负责人委托历史变更记录 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmsLeaderAgencyHistory bmsLeaderAgencyHistory)
    {
        List<BmsLeaderAgencyHistory> list = bmsLeaderAgencyHistoryService.selectBmsLeaderAgencyHistoryList(bmsLeaderAgencyHistory);
        ExcelUtil<BmsLeaderAgencyHistory> util = new ExcelUtil<BmsLeaderAgencyHistory>(BmsLeaderAgencyHistory.class);
        return util.exportExcel(list, "workflowAgencyHistory");
    }

    /**
     * 获取项目负责人委托历史变更记录 详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectLeaderWorkbeanch:workflowAgencyHistory:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(bmsLeaderAgencyHistoryService.selectBmsLeaderAgencyHistoryByGuid(guid));
    }

    /**
     * 新增项目负责人委托历史变更记录 
     */
    @PreAuthorize("@ss.hasPermi('projectLeaderWorkbeanch:workflowAgencyHistory:add')")
    @Log(title = "项目负责人委托历史变更记录 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsLeaderAgencyHistory bmsLeaderAgencyHistory)
    {
    	bmsLeaderAgencyHistory.setRemark("授权代理人");
        return toAjax(bmsLeaderAgencyHistoryService.insertBmsLeaderAgencyHistory(bmsLeaderAgencyHistory));
    }
    
    @Log(title = "项目负责人委托历史变更记录 ", businessType = BusinessType.INSERT)
    @PostMapping(value = "/cancleAgency")
    public AjaxResult cancleAgency(@RequestBody BmsLeaderAgencyHistory bmsLeaderAgencyHistory)
    {
    	bmsLeaderAgencyHistory.setRemark("取消代理人");
        return toAjax(bmsLeaderAgencyHistoryService.insertCancleBmsLeaderAgencyHistory(bmsLeaderAgencyHistory));
    }

    /**
     * 修改项目负责人委托历史变更记录 
     */
    @PreAuthorize("@ss.hasPermi('projectLeaderWorkbeanch:workflowAgencyHistory:edit')")
    @Log(title = "项目负责人委托历史变更记录 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsLeaderAgencyHistory bmsLeaderAgencyHistory)
    {
        return toAjax(bmsLeaderAgencyHistoryService.updateBmsLeaderAgencyHistory(bmsLeaderAgencyHistory));
    }

    /**
     * 删除项目负责人委托历史变更记录 
     */
    @PreAuthorize("@ss.hasPermi('projectLeaderWorkbeanch:workflowAgencyHistory:remove')")
    @Log(title = "项目负责人委托历史变更记录 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(bmsLeaderAgencyHistoryService.deleteBmsLeaderAgencyHistoryByGuids(guids));
    }
}
